//
//  View2Controller.swift
//  testDemo
//
//  Created by 张彦辉 on 2017/8/14.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit
import SnapKit
import Kingfisher

class View2Controller: UIViewController {
    
    var movie:Movie!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        
        let imageView = UIImageView()
        let imageUrl = URL(string: movie.image)
        imageView.kf.setImage(with: imageUrl, placeholder: UIImage(named: "a"))
        
        
        let nameTitle = UILabel()
        nameTitle.font = UIFont.boldSystemFont(ofSize: 12)
        nameTitle.text = "电影名称"
        
        
        
        let name = UILabel()
        name.font = UIFont.systemFont(ofSize: 12)
        name.text = movie.name
        
        
        let urlTitle = UILabel()
        urlTitle.text="下载地址"
        urlTitle.font = UIFont.boldSystemFont(ofSize: 12)
        
        
        
        let url = UILabel()
        url.text = movie.downURL
        url.font = UIFont.systemFont(ofSize: 12)
        
        
        let pwdTitle = UILabel()
        pwdTitle.text = "下载密码"
        pwdTitle.font = UIFont.boldSystemFont(ofSize: 12)
        
        
        let pwd = UILabel()
        pwd.font = UIFont.systemFont(ofSize: 12)
        pwd.text = movie.pwd
        
        
        
        
        
        self.view.addSubview(imageView)
        self.view.addSubview(nameTitle)
        self.view.addSubview(name)
        self.view.addSubview(urlTitle)
        self.view.addSubview(url)
        self.view.addSubview(pwdTitle)
        self.view.addSubview(pwd)
        
        //设置约束
        imageView.snp.makeConstraints { (maker) in
            maker.top.equalTo(100)
            maker.width.height.equalTo(150)
            maker.centerX.equalTo(self.view)
        }
        nameTitle.snp.makeConstraints { (maker) in
            maker.top.equalTo(imageView.snp.bottom).offset(20)
            maker.left.equalTo(20)
        }
        name.snp.makeConstraints { (maker) in
            maker.top.equalTo(nameTitle)
            maker.left.equalTo(nameTitle.snp.right).offset(20)
        }
        
        urlTitle.snp.makeConstraints { (maker) in
            maker.top.equalTo(nameTitle.snp.bottom).offset(20)
            maker.left.equalTo(nameTitle.snp.left)
        }
        
        url.snp.makeConstraints { (maker) in
            maker.top.equalTo(urlTitle)
            maker.left.equalTo(urlTitle.snp.right).offset(20)
        }
        
        pwdTitle.snp.makeConstraints { (maker) in
            maker.top.equalTo(urlTitle.snp.bottom).offset(20)
            maker.left.equalTo(urlTitle)
        }
        pwd.snp.makeConstraints { (maker) in
            maker.top.equalTo(pwdTitle)
            maker.left.equalTo(pwdTitle.snp.right).offset(20)
        }
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
